Skip to content

refactor(docs): read documented enum values through one shared reader - #12293

Merged
mergify[bot] merged 1 commit into
mainfrom
devs/kozlek/devs/kozlek/batch-status-data-type/read-documented-enum-values-one-shared-reader--e539de06
Aug 6, 2026
Merged

refactor(docs): read documented enum values through one shared reader#12293
mergify[bot] merged 1 commit into
mainfrom
devs/kozlek/devs/kozlek/batch-status-data-type/read-documented-enum-values-one-shared-reader--e539de06

Conversation

@kozlek

@kozlek kozlek commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

The engine is changing how it publishes per-value documentation for a
schema's choice set, moving from an x-enum-descriptions map to a
positional x-mergify-enum array that also carries a display title and a
deprecation flag. Schema syncs land as direct pushes to main, so the docs
repo cannot assume both sides move together.

Introduce readEnumChoices, which tolerates every shape a synced schema
can be in during that migration: values as a flat enum, a const, or
the anyOf of branches a composed Literal produces, with the node — or
any single branch of it — either inline or behind a $ref. Hoisting
repeated enums into shared components is what removes the duplicated
blocks from the published schema, and a reader that followed only the
property node would silently render an empty table once that happens.

Three things the shape change makes possible that the map could not, and
which are handled explicitly because each fails silently:

  • Metadata can sit on the referring node as a $ref sibling rather than
    on the target, which is how pydantic publishes an annotation for a
    hoisted type. Both are consulted, nearest first.
  • A positional array can fall out of alignment with enum in a way a
    keyed map never could. A length mismatch is treated as unusable rather
    than shifting every description onto the wrong value.
  • The two shapes can coexist on one node mid-migration, so they are
    merged rather than treated as alternatives.

Ref resolution uses the jsonpointer the sibling readers already use:
hand-decoding each segment raises URIError on a pointer containing a
stray %, which would break the never-throws contract this reader
depends on to degrade instead of failing the build.

The dequeue reason table moves onto it here; the batch status table is
written against it from the start in a later commit. Rendered output is
unchanged.

Part of MRGFY-8330

Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com

@kozlek

kozlek commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

This pull request is part of a Mergify stack:

# Pull Request Link
1 refactor(docs): read documented enum values through one shared reader #12293 👈
2 fix(docs): sanitize the HTML the schema-driven tables inject #12304
3 feat(docs): switch to the namespaced documented-data-type marker #12319
4 feat(docs): document the batch status data type #12263

@mergify
mergify Bot had a problem deploying to Mergify Merge Protections August 3, 2026 15:55 Failure
@mergify

mergify Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 All 6 merge protections satisfied — ready to merge.

Show 6 satisfied protections

🟢 🤖 Continuous Integration

  • all of:
    • check-success = build
    • check-success = lint
    • check-success = test
    • any of:
      • check-success = test-broken-links
      • label = ignore-broken-links
    • any of:
      • check-success=Cloudflare Pages
      • -head-repo-full-name~=^Mergifyio/

🟢 👀 Review Requirements

  • any of:
    • #approved-reviews-by >= 2
    • author = dependabot[bot]
    • all of:
      • author = mergify-ci-bot
      • -head ~= ^docs-agent/

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|internal|docs|style|refactor|perf|test|build|ci|chore|revert|ui)(?:\(.+\))?!?:

🟢 🔎 Reviews

  • #changes-requested-reviews-by = 0
  • #review-requested = 0
  • #review-threads-unresolved = 0

🟢 📕 PR description

  • body ~= (?ms:.{48,})

🟢 🚦 Auto-queue

When all merge protections are satisfied, this pull request will be queued automatically.

@mergify
mergify Bot requested a review from a team August 3, 2026 15:58
@kozlek
kozlek force-pushed the devs/kozlek/devs/kozlek/batch-status-data-type/read-documented-enum-values-one-shared-reader--e539de06 branch from b56a1a0 to 810fd13 Compare August 3, 2026 19:22
@kozlek
kozlek force-pushed the devs/kozlek/devs/kozlek/batch-status-data-type/document-batch-status-data-type--c5cd0801 branch from 5e644c7 to dc555d0 Compare August 3, 2026 19:22
@kozlek

kozlek commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Revision history

# Type Changes Reason Date
1 initial b56a1a0 2026-08-03 19:22 UTC
2 rebase b56a1a0 → 810fd13 (rebase only) 2026-08-03 19:22 UTC
3 content 810fd13 → 3cf3096 2026-08-04 07:58 UTC
4 content 3cf3096 → 3c3d836 2026-08-04 17:09 UTC
5 content 3c3d836 → f747840 2026-08-05 13:05 UTC
6 rebase f747840 → 4b1ec1f (rebase only) 2026-08-05 13:52 UTC
7 rebase 4b1ec1f → b5e84ba (rebase only) 2026-08-05 14:00 UTC
8 rebase 75807dc → 49cfdd4 (rebase only) 2026-08-06 07:53 UTC

@mergify
mergify Bot had a problem deploying to Mergify Merge Protections August 3, 2026 19:22 Failure
@kozlek
kozlek force-pushed the devs/kozlek/devs/kozlek/batch-status-data-type/document-batch-status-data-type--c5cd0801 branch from dc555d0 to fad7e3e Compare August 4, 2026 07:58
@kozlek
kozlek force-pushed the devs/kozlek/devs/kozlek/batch-status-data-type/read-documented-enum-values-one-shared-reader--e539de06 branch from 810fd13 to 3cf3096 Compare August 4, 2026 07:58
@mergify
mergify Bot had a problem deploying to Mergify Merge Protections August 4, 2026 07:58 Failure
@kozlek
kozlek changed the base branch from devs/kozlek/devs/kozlek/batch-status-data-type/document-batch-status-data-type--c5cd0801 to main August 4, 2026 17:09
Copilot AI lite review requested due to automatic review settings August 4, 2026 17:10
@kozlek
kozlek force-pushed the devs/kozlek/devs/kozlek/batch-status-data-type/read-documented-enum-values-one-shared-reader--e539de06 branch from 3cf3096 to 3c3d836 Compare August 4, 2026 17:10
@mergify
mergify Bot had a problem deploying to Mergify Merge Protections August 4, 2026 17:10 Failure

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a shared, schema-shape-tolerant reader for “choice sets” (enums + per-value documentation) to keep docs rendering stable across an engine-side schema migration from x-enum-descriptions to x-mergify-enum, including cases where enums are hoisted behind $ref.

Changes:

  • Added readEnumChoices (and supporting $ref resolution/metadata collection) to handle enum, const, and anyOf/oneOf choice shapes across both metadata formats.
  • Added Vitest coverage to pin expected behavior for migration edge cases (ref siblings, hoisted enums, misaligned positional metadata, etc.).
  • Refactored QueueDequeueReasons to use the shared reader rather than bespoke enum/description extraction.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/util/enumChoices.ts New shared enum-choice reader with $ref resolution and merged legacy/target metadata handling.
src/util/enumChoices.test.ts New unit tests covering multiple schema shapes and migration failure modes.
src/components/Tables/QueueDequeueReasons.tsx Switched dequeue reason table generation to readEnumChoices for migration-safe rendering.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/util/enumChoices.ts
@kozlek
kozlek force-pushed the devs/kozlek/devs/kozlek/batch-status-data-type/read-documented-enum-values-one-shared-reader--e539de06 branch from 3c3d836 to f747840 Compare August 5, 2026 13:05
@mergify
mergify Bot had a problem deploying to Mergify Merge Protections August 5, 2026 13:05 Failure
@kozlek
kozlek marked this pull request as ready for review August 5, 2026 13:38
@kozlek
kozlek force-pushed the devs/kozlek/devs/kozlek/batch-status-data-type/read-documented-enum-values-one-shared-reader--e539de06 branch from f747840 to 4b1ec1f Compare August 5, 2026 13:52
@mergify
mergify Bot had a problem deploying to Mergify Merge Protections August 5, 2026 13:54 Failure
@kozlek
kozlek force-pushed the devs/kozlek/devs/kozlek/batch-status-data-type/read-documented-enum-values-one-shared-reader--e539de06 branch from 4b1ec1f to b5e84ba Compare August 5, 2026 14:01
@kozlek
kozlek changed the base branch from main to devs/kozlek/devs/kozlek/batch-status-data-type/show-accepted-values-api-params-typed-shared-enum--c546133c August 5, 2026 14:01
@mergify
mergify Bot had a problem deploying to Mergify Merge Protections August 5, 2026 14:01 Failure
JulianMaurin
JulianMaurin previously approved these changes Aug 5, 2026
@mergify
mergify Bot requested a review from a team August 5, 2026 14:03
Base automatically changed from devs/kozlek/devs/kozlek/batch-status-data-type/show-accepted-values-api-params-typed-shared-enum--c546133c to main August 6, 2026 07:04
@mergify
mergify Bot dismissed JulianMaurin’s stale review August 6, 2026 07:04

The base branch was changed.

@mergify
mergify Bot force-pushed the devs/kozlek/devs/kozlek/batch-status-data-type/read-documented-enum-values-one-shared-reader--e539de06 branch from b5e84ba to 75807dc Compare August 6, 2026 07:04
@mergify
mergify Bot had a problem deploying to Mergify Merge Protections August 6, 2026 07:05 Failure
JulianMaurin
JulianMaurin previously approved these changes Aug 6, 2026
@mergify
mergify Bot requested a review from a team August 6, 2026 07:13
The engine is changing how it publishes per-value documentation for a
schema's choice set, moving from an `x-enum-descriptions` map to a
positional `x-mergify-enum` array that also carries a display title and a
deprecation flag. Schema syncs land as direct pushes to main, so the docs
repo cannot assume both sides move together.

Introduce `readEnumChoices`, which tolerates every shape a synced schema
can be in during that migration: values as a flat `enum`, a `const`, or
the `anyOf` of branches a composed `Literal` produces, with the node — or
any single branch of it — either inline or behind a `$ref`. Hoisting
repeated enums into shared components is what removes the duplicated
blocks from the published schema, and a reader that followed only the
property node would silently render an empty table once that happens.

Three things the shape change makes possible that the map could not, and
which are handled explicitly because each fails silently:

- Metadata can sit on the referring node as a `$ref` sibling rather than
  on the target, which is how pydantic publishes an annotation for a
  hoisted type. Both are consulted, nearest first.
- A positional array can fall out of alignment with `enum` in a way a
  keyed map never could. A length mismatch is treated as unusable rather
  than shifting every description onto the wrong value.
- The two shapes can coexist on one node mid-migration, so they are
  merged rather than treated as alternatives.

Ref resolution uses the `jsonpointer` the sibling readers already use:
hand-decoding each segment raises `URIError` on a pointer containing a
stray `%`, which would break the never-throws contract this reader
depends on to degrade instead of failing the build.

The dequeue reason table moves onto it here; the batch status table is
written against it from the start in a later commit. Rendered output is
unchanged.

Part of MRGFY-8330

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Change-Id: Ie539de06bf3391eb4390333810cda6e8f131b1e6
@kozlek
kozlek force-pushed the devs/kozlek/devs/kozlek/batch-status-data-type/read-documented-enum-values-one-shared-reader--e539de06 branch from 75807dc to 49cfdd4 Compare August 6, 2026 07:53
@mergify
mergify Bot dismissed JulianMaurin’s stale review August 6, 2026 07:53

Pull request has been modified.

@mergify
mergify Bot deployed to Mergify Merge Protections August 6, 2026 07:54 Active
@mergify
mergify Bot requested a review from a team August 6, 2026 08:00
@mergify

mergify Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 2 minutes 45 seconds in the queue, including 2 minutes 26 seconds running CI.

Required conditions to merge

@mergify mergify Bot added the queued label Aug 6, 2026
@mergify
mergify Bot merged commit d122a6d into main Aug 6, 2026
10 of 17 checks passed
@mergify
mergify Bot deleted the devs/kozlek/devs/kozlek/batch-status-data-type/read-documented-enum-values-one-shared-reader--e539de06 branch August 6, 2026 08:12
@mergify mergify Bot removed the queued label Aug 6, 2026
mergify Bot pushed a commit that referenced this pull request Aug 6, 2026
`renderMarkdown` output goes straight into `dangerouslySetInnerHTML` in
six tables, and it did not filter URL protocols: `remark-rehype` emits an
`<a>` for any link target whatever its scheme, so a `javascript:` link in
a synced description would have rendered as a live link.

Raw HTML was never a way in — `remark-rehype` runs without
`allowDangerousHtml`, so it is discarded before becoming a node — which
makes URL filtering the whole of what `rehype-sanitize` adds here. It
sits after `rehype-raw` so that if a caller ever does enable
`allowDangerousHtml`, the embedded markup is parsed and then sanitized
rather than passed through opaque.

Every input today is first-party: descriptions generated by our own
engine and delivered by our own sync bot. So this is defence in depth
rather than a live exposure — but "the input is trustworthy" is a
property of the six current callers, not of the function, and the output
lands somewhere that makes the distinction expensive to get wrong later.

The tests separate the two guarantees on purpose. Asserting all four
cases together would have been misleading: three of them pass with the
sanitizer removed, because they test the markdown pipeline discarding raw
HTML rather than anything the sanitizer does. Only the URL-protocol cases
fail if it goes.

Output is unchanged across every description the two schemas publish.

Part of MRGFY-8330

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

Depends-On: #12293
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants